﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace UIT_CV_Management
{
    static class Language
    {
        private static String[,] LanguageCode = new String[,] { {"en", "English"},
                                                               {"vi", "Vietnamese"} };
        public static String CurrentLanguage = "en";
        public static String _(String _Word)
        {
            String SQL = "SELECT " + LanguageName(CurrentLanguage) +
                " FROM Translations WHERE Pharse = '" + _Word + "'";
            QueryResult result = Database.shareDatabase.Query(SQL);
            if (result.ReturnCode == 200)
                return result.Table.Rows[0][0].ToString().Replace("\\n", "\n");
            return _Word;
        }

        private static String LanguageName(String _LanguageCode) {
            if (_LanguageCode == null) _LanguageCode = "en";
            for (int i = 0; i < LanguageCode.Length / 2; i++)
                if (LanguageCode[i, 0] == _LanguageCode) return LanguageCode[i, 1];
            return _LanguageCode;
        }
    }
}
